package com.laozhao.EasySales.business;

import javax.swing.JMenuBar;

import com.laozhao.EasySales.control.MainWindowsAction;
import com.laozhao.EasySales.zgui.ZMenu;
import com.laozhao.EasySales.zgui.ZMenuItem;
import com.laozhao.dreamframe.util.FrameFactory;


public class MenuUtil {
	
	JMenuBar menuBar = new JMenuBar();

	ZMenu menuSales = new ZMenu("Sales");
	ZMenuItem menuSalesReport = new ZMenuItem("SalesReport");

	ZMenu menuPurchase = new ZMenu("Purchase");
	ZMenuItem menuPurchaseReport = new ZMenuItem("PurchaseReport");

	ZMenu menuAccount = new ZMenu("Account");
	ZMenuItem menuAccountReport = new ZMenuItem("AccountReport");
	ZMenuItem menuDeptReport = new ZMenuItem("DeptReport");
	ZMenuItem menuDetailReport = new ZMenuItem("DetailReport");

	ZMenu menuMaster = new ZMenu("Master");
	ZMenuItem menuCustomer = new ZMenuItem("Customer");
	ZMenuItem menuShop = new ZMenuItem("Shop");
	ZMenuItem menuSalesman = new ZMenuItem("Salesman");
	ZMenuItem menuGoods= new ZMenuItem("Goods");

	ZMenu menuHelp = new ZMenu("Help");
	ZMenuItem menuCalculator = new ZMenuItem("Calculator");
	ZMenuItem menuSql = new ZMenuItem("Sql");
	ZMenuItem menuAbout = new ZMenuItem("About");
	
	
	public MenuUtil(){
		MainWindowsAction mainWindowAction = (MainWindowsAction) FrameFactory.getInstance(MainWindowsAction.class);

		menuSalesReport.addActionListener(mainWindowAction);
		menuPurchaseReport.addActionListener(mainWindowAction);
		menuAccountReport.addActionListener(mainWindowAction);
		menuDeptReport.addActionListener(mainWindowAction);
		menuDetailReport.addActionListener(mainWindowAction);
		menuCustomer.addActionListener(mainWindowAction);
		menuShop.addActionListener(mainWindowAction);
		menuSalesman.addActionListener(mainWindowAction);
		menuGoods.addActionListener(mainWindowAction);
		menuCalculator.addActionListener(mainWindowAction);
		menuSql.addActionListener(mainWindowAction);
		menuAbout.addActionListener(mainWindowAction);
		
		menuSalesReport.setActionCommand("menuSalesReport");
		menuPurchaseReport.setActionCommand("menuPurchaseReport");
		menuAccountReport.setActionCommand("menuAccountReport");
		menuDeptReport.setActionCommand("menuDeptReport");
		menuDetailReport.setActionCommand("menuDetailReport");
		menuCustomer.setActionCommand("menuCustomer");
		menuShop.setActionCommand("menuShop");
		menuSalesman.setActionCommand("menuSalesman");
		menuGoods.setActionCommand("menuGoods");
		menuCalculator.setActionCommand("menuCalculator");
		menuSql.setActionCommand("menuSql");
		menuAbout.setActionCommand("menuAbout");
	}

	public JMenuBar getJMenuBar() {

		menuSales.add(menuSalesReport);
		menuPurchase.add(menuPurchaseReport);
		menuAccount.add(menuAccountReport);
		menuAccount.add(menuDeptReport);
		menuAccount.add(menuDetailReport);
		menuMaster.add(menuCustomer);
		menuMaster.add(menuShop);
		menuMaster.add(menuSalesman);
		menuMaster.add(menuGoods);
		menuHelp.add(menuCalculator);
		menuHelp.add(menuSql);
		menuHelp.add(menuAbout);

		menuBar.add(menuSales);
		menuBar.add(menuPurchase);
		menuBar.add(menuAccount);
		menuBar.add(menuMaster);
		menuBar.add(menuHelp);
		
		return menuBar;
	}
}
